package com.peacebird.ec.api.controller;

import com.peacebird.ec.api.dto.ReturnT;
import com.peacebird.ec.api.model.ShopPasswordInfo;
import com.peacebird.ec.api.service.ShopPasswordInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: ZYZ
 * @DateTime: 2020/3/5 18:14
 * @Description:
 */

@RestController
public class ShopPasswordInfoController {

    @Autowired
    ShopPasswordInfoService shopPasswordInfoService;

    @GetMapping("/shoppwdinfo/{shopId}")
    public Object getShopPasswordInfoByShopId(@PathVariable(name = "shopId", required = true) String shopId){
        ShopPasswordInfo shopPasswordInfo = shopPasswordInfoService.getShopPasswordByShopId(shopId);
        return new ReturnT<ShopPasswordInfo>(shopPasswordInfo);
    }

    @GetMapping("/shoppwd/{shopId}")
    public String getShopPasswordByShopId(@PathVariable(name = "shopId", required = true) String shopId){
        ShopPasswordInfo shopPasswordInfo = shopPasswordInfoService.getShopPasswordByShopId(shopId);
        if (shopPasswordInfo == null) {
            return "";
        }
        return shopPasswordInfo.getShopPWD();
    }

    @GetMapping("/shopname/{shopId}")
    public String getShopNameByShopId(@PathVariable(name = "shopId", required = true) String shopId){
        ShopPasswordInfo shopPasswordInfo = shopPasswordInfoService.getShopPasswordByShopId(shopId);
        if (shopPasswordInfo == null) {
            return "";
        }
        return shopPasswordInfo.getShopName();
    }
}
